<?php

/*
  VoIP Wholesale 1.0
  ------------------
  Document   : module_external_home
  Created on : Sep 14, 2011, 4:32:27 PM
  Author     : Milos Jovanovic <miloscode@gmail.com>
  Description:

 */
?>
<div id="page-title"><?=lang('term_internal_numbering_plan')?></div>

<div id="page-desc"><?=lang('text_internal_numbering_plan_desc')?></div>

<div class="ui-widget"> 
    <div id="content">
        <!-- PAGE CONTENT -->
        
        <div class="module-options">
            <button id="module-add-new-internal"><?=lang('button_add_new_entry')?></button>
            <button id="module-export-xls"><?=lang('button_export_xls')?></button>
            <button id="module-import-xls"><?=lang('button_import_xls')?></button>
        </div>
        
        <fieldset class="ui-widget-content ui-state-active">

            <legend class="ui-widget-content ui-state-active"><?=lang('form_filters')?></legend>
                
            <form action="<?=MODULE_SITE_URL?>/internal/" method="post">
                <table>
                <tr>
                    <td>
                        <select name='data[country_id]' id="country" <?php if(isset($country_id) && $country_id != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_country')?></option>
                            <?php
                            foreach($countries as $country)
                            {
                            ?>
                            <option value="<?=$country->id?>" <?php if(@$country_id == $country->id){?>selected="selected"<?php }?>><?=$country->country_name?></option>
                            <?php        
                              }
                            ?>
                        </select>
                    </td>
                    <td>
                        <select name='data[route_name]' id="route_name" <?php if(isset($route_name) && $route_name != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('term_route_name')?></option>
                        </select>
                    </td>					
                    <td>
                            <input type="text" name="data[dialling_code]" value="<?php if(@$dialling_code > 0){print $dialling_code;}else{print lang('form_dialcode_begins_with');}?>" id="dialling_code_field" <?php if(@$dialling_code > 0){?>class="ui-state-error"<?php }?>/>
                    </td>
                    <td>
                        <select name="data[status]" <?php if(isset($status) && @$status != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_status')?></option>
                            <option value="all" <?php if(@$status == "all"){?>selected="selected"<?php }?>><?=lang('term_all')?></option>
                            <option value="open" <?php if(@$status == "open"){?>selected="selected"<?php }?>><?=lang('term_open')?></option>
							<option value="closed" <?php if(@$status == "closed"){?>selected="selected"<?php }?>><?=lang('term_closed')?></option>
                        </select>
                    </td>
                    <td>
                        <select name="data[type]" <?php if(isset($type) && @$type != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('term_type')?></option>
                            <option value="all" <?php if(@$type == "all"){?>selected="selected"<?php }?>><?=lang('term_all')?></option>
                            <option value="proper" <?php if(@$type == "proper"){?>selected="selected"<?php }?>><?=lang('term_proper')?></option>
                            <option value="mobile" <?php if(@$type == "mobile"){?>selected="selected"<?php }?>><?=lang('term_mobile')?></option>
                        </select>
                    </td>
                    <td>
                        <select name="data[num_of_results]" <?php if(isset($num_of_results) && @$num_of_results != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_max_results')?></option>
                            <option value="20" <?php if(@$num_of_results == "20"){?>selected="selected"<?php }?>>20</option>
                            <option value="50" <?php if(@$num_of_results == "50"){?>selected="selected"<?php }?>>50</option>
                            <option value="100" <?php if(@$num_of_results == "100"){?>selected="selected"<?php }?>>100</option>
                            <option value="200" <?php if(@$num_of_results == "200"){?>selected="selected"<?php }?>>200</option>
                            <option value="500" <?php if(@$num_of_results == "500"){?>selected="selected"<?php }?>>500</option>
                        </select>
                    </td>
                    <td>
                            <button id="filter-submit"><?=lang('term_search')?></button>
                    </td>
                </tr>
                </table>
            </form>                
        </fieldset>
        <br />
        <!-- table with the entries -->
	<table class="ui-widget ui-widget-content module-table-num-plan" id="routes-table"> 
		<thead> 
			<tr class="ui-widget-header "> 
				<!--<th class="module-1st">#</th> -->
				<th class="module-2nd"><?=lang('term_name')?></th> 
                <th class="module-3rd"><?=lang('term_dial_code')?></th> 
				<th class="module-4th"><?=lang('term_country')?></th> 												
				<th class="module-5th"><?=lang('term_type')?></th> 												
                <th class="module-6th"><?=lang('term_date_from')?></th> 
                <th class="module-7th"><?=lang('term_date_to')?></th> 
                <th class="module-8th"><?=lang('term_status')?></th> 
				<th class="module-9th"><?=lang('term_actions')?></th> 							
			</tr> 
		</thead> 
		<tbody> 
		<?php $num=1;
		if(is_array($routes)){
		foreach($routes as $route){
		$country = $this->PACKAGE->regional->countries->get_country_as_array_from_id($route['country_id']);?>
			<tr> 
                <!--<td><?=$num?></td>-->
                <td class="module-2nd"><?=$route['name']?></td> 
                <td class="module-3rd"><?=$route['dialling_code']?></td> 
				<td class="module-4th"><?=$country['country_name']?></td>
				<td class="module-5th"><?=$this->module_translate->route_type_word($route['type'])?></td> 				
				<td class="module-6th"><?=date('Y-m-d',strtotime($route['start_date']))?></td> 
				<td class="module-7th"><?=date('Y-m-d',strtotime($route['exp_date']))?></td> 
				<td class="module-8th" <?php if($route['status'] ==3){?>style="color:red;"<?php }?>><?=$this->module_translate->route_status_word($route['status'])?></td> 
				<td class="module-9th"><button class="options" id="<?=$route['id']?>" rel="<?=$route['status']?>"><span><?=$this->module_translate->route_option($route['status'])?></span></button></td>
			</tr> 
		<?php 
		$num++;}}?>
		</tbody> 
	</table> 

    </div>    
</div>   